package com.itheima;

import java.util.Scanner;

public class Demo7 {
    public static void main(String[] args) {
        int[] arr = new int[6];
        int sum = 0;
        for (int i = 0; i < arr.length; i++) {
            Scanner sc = new Scanner(System.in);
            System.out.println("请输入第" + (i + 1) + "成绩");
            int cj = sc.nextInt();
            if (cj >= 0 && cj <= 100) {
                arr[i] = cj;
            } else {
                System.out.println("输入的成绩有误,请重新输入");
                i--;
            }
            sum += arr[i];
        }
        System.out.println("成绩和为:" + sum);

        int zd = getMax(arr);
        System.out.println("最大值为" + zd);

        int zx = getMin(arr);
        System.out.println("最小值为:" + zx);

        int pj=(sum-zd-zx)/4;
        System.out.println("平均分为:"+pj);
    }

    public static int getMax(int[] arr) {
        int max =arr[0];
        for (int i = 1; i < arr.length; i++) {
            if (arr[i] > max) {
                max = arr[i];
            }
        }
        return max;
    }

    public static int getMin(int[] arr) {
        int min =arr[0];
        for (int i = 1; i < arr.length; i++) {
            if (arr[i] < min) {
                min = arr[i];
            }
        }
        return min;
    }
}
